capture log close
log using crisis_rep_VOTER, replace text
//program:  crisis_rep_VOTER.do
//task:    Replication of VOTER analyses
//project: Politics of Personal Crisis (Ojeda, Michener & Haselswerdt), Political Behavior     
//author: Jake Haselswerdt \ 2024-3-8

//program setup
version 15
clear all
set linesize 80
macro drop _all
set scheme s1mono
graph set window fontface "GillSans"
set more off

use VOTER_2019vv_crisis.dta, clear
svyset [pweight=weight1_2019]

//Appendix C: Descriptives
foreach d in difficulty_you_2018_01 difficulty_spou_2018_01 difficulty_morg_2018_01 difficulty_load_2018_01 difficulty_car_2018_01 difficulty_cred_2018_01 difficulty_inc_2018_01{
di "`: var label `d''"
svy: proportion `d'
}
svy: proportion difficulty_2018_count

sum voted_2018_TS difficulty_2018_count voted_2016_TS educ_2016 female black hisp other age faminc_clean_2016 churchattend_2016 married_2016 [aw=weight1_2019]

// Figure 1: Histogram/Frequency Distribution
graph twoway (hist difficulty_2018_count, discrete percent fcolor(gs10) lcolor(white)), ///
	title("VOTER") ///
	xtitle("Count of Negative Life Events") ///
	xlabel(0 2 4 6 8, labsize(2.5)) ///
	xtick(0(1)8) ///
	ytitle("Percentage of Respondents") ///
	ylabel(0(10)70, labsize(2.5) angle(horizontal)) ///	
	yscale(titlegap(2)) ///
	xscale(titlegap(2)) ///
	graphregion(fcolor(white)) ///
	scheme(s1mono) graphregion(fcolor(white)) aspect(1) graphregion(margin(r 40)) ///
	saving(voter_hist, replace)

// Table 2 / Appendix D: T-test Results

foreach var of varlist difficulty_you_2018_01 difficulty_spou_2018_01 difficulty_morg_2018_01 difficulty_load_2018_01 difficulty_car_2018_01 difficulty_cred_2018_01 difficulty_inc_2018_01{
di ""
di "`:variable label `var''"
ttest voted_2018_TS, by(`var')
di ""
}

// Table 3: Cross-tabulation of crisis terciles with voting	
tab difficulty_2018_lomedhi, sum(difficulty_2018_count)
svy: tab voted_2018_TS difficulty_2018_lomedhi, col		

// Table 4 & Appendix E: Logistic regressions of voting on personal crisis
svy: logit voted_2018_TS difficulty_2018_count voted_2016_TS educ_2016 female black hisp other age faminc_clean_2016 churchattend_2016 married_2016 child18_2016_01

//Appendix C: Descriptives
foreach d in difficulty_you_2018_01 difficulty_spou_2018_01 difficulty_morg_2018_01 difficulty_load_2018_01 difficulty_car_2018_01 difficulty_cred_2018_01 difficulty_inc_2018_01{
di "`: var label `d''"
svy: proportion `d'
}
svy: proportion difficulty_2018_count

sum voted_2018_TS difficulty_2018_count voted_2016_TS educ_2016 female black hisp other age faminc_clean_2016 churchattend_2016 married_2016 [aw=weight1_2019]

// Appendix F: Demographics and Crises
tab female, sum(difficulty_2018_count)

gen age_cat = .
replace age_cat = 1 if age < 36
replace age_cat = 2 if age > 35
replace age_cat = 3 if age > 55
tab age_cat, sum(difficulty_2018_count)
drop age_cat

gen race_new = race_2019
recode race_new 5=4 6=4 7=4 8=4
tab race_new, sum(difficulty_2018_count)
drop race_new

gen educ_degree = educ_2019
recode educ_degree 4=4 5=4 6=4
tab educ_degree, sum(difficulty_2018_count)
drop educ_degree

xtile income_quintile = faminc_clean_2018, nq(5)
tab income_quintile, sum(difficulty_2018_count)
drop income_quintile
			
svy: tab voted_2018_TS

// Appendix G: Heterogeneous effects

*Dichotomous variables
foreach v in voted_2016_TS female white black hisp child18_2016_01{
di "`: var label `v''"
svy: logit voted_2018_TS c.difficulty_2018_count##i.`v' voted_2016_TS educ_2016 female black hisp other age faminc_clean_2016 churchattend_2016 married_2016 child18_2016_01
}

*Continuous/ordinal
foreach v in age faminc_clean_2016 educ_2016 pol_interest_2017{
di "`: var label `v''"
svy: logit voted_2018_TS c.difficulty_2018_count##c.`v' voted_2016_TS educ_2016 female black hisp other age faminc_clean_2016 churchattend_2016 married_2016 child18_2016_01
}

log close
exit
